// 求一维数组任意区间和
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
int n, m;
int a[N], f[N];

int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        f[i] = f[i-1] + a[i];
    }
    cin >> m; // m次查询
    while(m--){
        int l, r; 
        cin >> l >> r;
        int ret = f[r] - f[l-1]; 
        cout << ret << '\n';
    }
    return 0;
}